// Copyright  2012 Petr TALLA. [petr.talla@gmail.com]
// This file is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY;  without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
// [http://www.gnu.org/copyleft/lesser.html]
//=============================================================================

package tc.common.symbology;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.geom.Point2D;
import java.util.Vector;

public class Symbol {
	public String id;
	public Vector<SymbolItem> items = new Vector<SymbolItem>();
	
	static public final int DIM = 800;
	
	static public Point createPoint(double x, double y) {
		Point result = new Point((int)((double)DIM*x), -(int)((double)DIM*y)); 
		return result;
	}
	
	static public Point computePoint(double x, double y) {
		int x2 = (int)(x*Symbol.DIM);
		int y2 = (int)(y*Symbol.DIM);
		return new Point(x2, y2);
	}
	
	static public Point2D.Double createPointStorage(Point pt) {
		return new Point2D.Double( (double)pt.x/(double)DIM, -(double)pt.y/(double)DIM );
	}
	
	public Symbol(String id) {
		this.id = id;
	}
	
	public void display(Graphics g, int x, int y, int kx, int ky ) {
		Color oldColor = g.getColor();
		for (int i = 0; i < items.size(); i++ ) items.get(i).display(g, x, y, kx, ky);
		g.setColor(oldColor);
	}
	
	public void displayRot(Graphics g, int x, int y, int ox, int oy, int kx, int ky, int dirx, int diry ) {
		Color oldColor = g.getColor();
		for (int i = 0; i < items.size(); i++ ) items.get(i).displayRot(g, x, y, ox, oy, kx, ky, dirx, diry);
		g.setColor(oldColor);
	}
}
